package org.dtrd.modules.archive.entity.bean.report;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.dtrd.config.system.Constant;
import org.dtrd.modules.archive.entity.po.DtrdEntRdArchiveAnamnesis;

import java.util.Date;

/**
 * <p>
 * 既往病史和过敏史
 * </p>
 *
 * @author QR
 * @since 2022-01-21
 */
@Getter
@Setter
@ApiModel(value = "既往病史和过敏史详情")
public class AnamnesisReport {

    @ApiModelProperty("有无低血糖发生史")
    private String hypoglycemiaIsExistText;
    @ApiModelProperty("低血糖发生频率")
    private String hypoglycemiaFrequency;
    @ApiModelProperty("低血糖原因")
    private String hypoglycemiaCause;
    @ApiModelProperty("低血糖症状")
    private String hypoglycemiaSymptom;


    @ApiModelProperty("有无糖尿病酮症酸中毒发生史")
    private String ketoacidosisText;
    @ApiModelProperty("糖尿病酮症酸中毒原因")
    private String ketoacidosisCause;
    @ApiModelProperty("糖尿病酮症酸中毒程度")
    private String ketoacidosisDegreeText;
    @ApiModelProperty("糖尿病酮症酸中毒发生频率")
    private String ketoacidosisFrequency;
    @ApiModelProperty("糖尿病酮症酸中毒尿胴体检查")
    private String ketoacidosisUrineKetoneText;
    @ApiModelProperty("糖尿病酮症酸中毒血胴体检查")
    private String ketoacidosisBloodKetone;


    @ApiModelProperty("有无糖尿病高渗综合征发生史")
    private String dnhsText;
    @ApiModelProperty("糖尿病高渗综合征发生频率")
    private String dnhsFrequency;

    @ApiModelProperty("有无糖尿病乳酸酸中毒发生史")
    private String lacticAcidosisText;
    @ApiModelProperty("糖尿病乳酸酸中毒发生频率")
    private String lacticAcidosisFrequency;

    @ApiModelProperty("有无其他原因导致肾脏疾病")
    private String kidneyText;
    @ApiModelProperty("所患肾脏疾病")
    private String kidneyDisease;
    @ApiModelProperty("所患肾脏疾病确诊日期")
    @JsonFormat(pattern = Constant.TIME_PATTERN_SDF, timezone = "GMT+8")
    private Date kidneyDiseaseDate;
    @ApiModelProperty("所患肾脏疾病相关检查")
    private String kidneyData;

    @ApiModelProperty("其他病史")
    private String otherDiseaseOther;

    public AnamnesisReport parseFromPO(DtrdEntRdArchiveAnamnesis po) {
        Constant.DiabetesDiagnose confirm = Constant.DiabetesDiagnose.DIAGNOSE;
        Integer dnhs = po.getDnhs();
        if (dnhs != null && dnhs.equals(confirm.getType())) {
            dnhsText = confirm.getName();
            if (po.getDnhsFrequency() != null) {
                dnhsFrequency = po.getDnhsFrequency() + "次/周";
            }
        }
        Integer acidosis = po.getLacticAcidosis();
        if (acidosis != null && acidosis.equals(confirm.getType())) {
            lacticAcidosisText = confirm.getName();
            if (po.getLacticAcidosisFrequency() != null) {
                lacticAcidosisFrequency = po.getLacticAcidosisFrequency() + "次/周";
            }
        }
        return this;
    }
}
